var LevelAllDone = {
    _util: new Util(),
    _manage: null,
    _layer: null,
    _refer: null,
    init: function(){
        this._util.onAssignCCBMemberVariable(this.assignActive());
        var layerNode = this._util.newLayerFromCCB(s_levelEnd_ccbi, this._refer);
        this._layer = layerNode;
        this._manage = this._util.ccbReader.getAnimationManager();
        this._manage.setCompletedAnimationCallback(this, this.onCCBAnimEnd);
        
        if (layerNode != null) {
            this._refer.addChild(layerNode, 2);
        }
        
    },
    onEnter: function(refer){
        cc.log("level_end -> onEnter")
        this._refer = refer;
        this.init();
        this.outAction = null;
    },
    onMainMenu: function(){
        if (this._manage.getRunningSequenceName() != "Out") {
            var $this = this;
            this._manage.runAnimations("Out");
            this.outAction = function(){
                $this._layer.removeFromParent(true);
                game.backToMainMenu();
            }
        }
    },
    assignActive: function(){
        var arr = new Array();
        var $this = this;
        arr.push({
            key: "btnMainMenu",
            callback: function(){
                sound.playButtonSound();
                $this.onMainMenu();
            }
        });
        return arr;
    },
    outAction: null,
    onCCBAnimEnd: function(){
        var animName = this._manage.getLastCompletedSequenceName();
        if (animName == "Out") {
            if (this.outAction != null) {
                this.outAction();
            }
        }
    }
}
